<?php
class indexAction extends baseAction {
	function index() {
		//var_dump(__APP__);exit;
		$focus_mod = D('focus');
		$index_group_cates = $this->get_index_group_cates();
		//热门活动
		$article_mod = M('article');
		$top_actives = $article_mod->where('cate_id=9')->where('is_best=1')->order('add_time DESC')->find();
		$this->assign('top_actives', $top_actives);
		$hot_actives = $article_mod->where('cate_id=9')->limit('0,4')->order('is_hot DESC,add_time DESC')->select();
		$this->assign('index_group_cates', $index_group_cates);
		$this->assign('hot_actives', $hot_actives);
		$ad_list = $focus_mod->where('cate_id=1 AND status=1')->order('ordid DESC')->select();
		$this->assign('ad_list', $ad_list);

		$this->assign('seo', $this->seo);
		$this->display();
	}

	function get_index_group_cates() {
		$items_cate_mod = M('items_cate');
		$items=M("items");
		//查找需要显示的大分类
		$index_group_cates = $items_cate_mod->where("pid=0 AND is_hots=1")->select();
		foreach ($index_group_cates as $key => $val) {
			//排序查找子分类
			$index_group_cates[$key]['s'] = $items_cate_mod->where("pid=" . $val['id'])->limit("0,10")->order("ordid DESC")->select();
			//查找需要首页显示的子分类
			$g_result = $items_cate_mod->where("pid=" . $val['id'] . " AND is_hots=1")->order("ordid DESC")->select();
			foreach ($g_result as $gkey => $gval) {
				$g_result[$gkey]['items'] = $this->get_group_items($gval['id']);
			}
			//查询下面9个显示首页的商品图片
			$index_group_cates[$key]['g'] = $g_result;
		}
		//print_r($index_group_cates);exit;
		return $index_group_cates;
	}
}